import Vue from 'vue'
import VueRouter from 'vue-router'
// import DashBoard from '@/views/DashBoard.vue'
// import Login from '@/views/Login.vue'
// import Share from '@/views/Share.vue'

// import Employee from '../views/Employee'
// import Setting from '../views/Setting'
import Shop from '@/views/Shop.vue'


Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: Shop,
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

/*
  当浏览器地址发生变化时

  1. 全局 beforeEach
  2. 组件 beforeRouteUpdate 
  3. 路由配置 beforeEnter
  4. 组件 beforeRouteEnter
  5. 全局 beforeResolve
  6. 全局 beforeEach
  7. 更新 DOM
*/

// router.beforeEach((to, from, next) => {
//   // 只要访问的页面不是 login, 我们都做登录检查
//   if (to.path !== '/login') {
//     if (window.localStorage['isLogin']) {
//       next()
//     } else {
//       next(`/login?redirect=${to.path}`);
//     }
//   } else {
//     next()
//   }
// })

export default router
